package snake

import (
	"container/list"
	"github.com/nsf/termbox-go"
	"time"
)

const (
	width        = 52
	height       = 26
	left         = 10
	top          = 2
	fgColor      = termbox.ColorDefault
	bgColor      = termbox.ColorDefault
	foodFgColor  = termbox.ColorRed
	foodBgColor  = termbox.ColorRed
	snakeFgColor = termbox.ColorBlue
	snakeBgColor = termbox.ColorBlue
)

var (
	snake              *engine
	keyboardEventsChan = make(chan keyboardEvent)
)

type keyboardEvent struct {
	eventType string
}

type Cell struct {
	x      int
	y      int
	Fg     termbox.Attribute
	Bg     termbox.Attribute
	occupy bool
}

type engine struct {
	w          int //宽度
	h          int //高度
	marginLeft int
	marginTop  int
	score      int                 //分数
	globalMap  [height][width]Cell //全局图形
	hard       int                 //难度等级
	speed      time.Duration       //移动速度
	state      int8                //状态 0开始 1暂停
	c          *time.Ticker
	list       *list.List
	food       []Cell
	direction  string
	gameOver   bool
}
